﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cn.Edwon.Web.Support;
using Cn.Edwon.Biz;
using Cn.Edwon.Spring;
using Cn.Cellula.Model.Content;
using Cn.Edwon.Web.Script;

namespace Cn.Cellula.MiniTopSite.Ws {
    public partial class _Msg : PageSupport {
        String MsgKey;
        String Mode;
        IBiz biz = BizFactory.Get<IBiz>();
        protected void Page_Load(object sender, EventArgs e) {
            if (this.Actor == null) {
                Mode = Request.QueryString["mode"];
                MsgKey = Request.QueryString["msgid"];
                if (Mode == "new") {
                    ResponseOut(LoadNewMsg());
                } else {
                    ResponseOut("{\"ex\":\"WebService Error:$nUnkonwn Action\"}");
                }
            } else {
                ResponseOut("{\"ex\":\"WebService Error:$nNot login\"}");
            }
        }
        private void ResponseOut(String rContent) {
            Response.Clear();
            Response.Write(rContent);
            Response.End();
        }

        private String LoadNewMsg() {
            IList<Object> list = biz.Find<Object>("from TMsgEO eo where eo.Reciver='"+this.Actor.ID+"' and eo.IsRead=0 order by eo.SendDate");
            return JsUtil.ParseEOList2Json(list);
        }
    }
}